<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>侦听器-正方形面积</title>
  <script src="vue.js"></script>
</head>
<body>
  <script>
    let square = {
      length:2,
      area:4
    };

    let vm = new Vue({
      data: square,
      watch: {
        length(value){
          this.area = value * value; //想像这个乘法计算是一个耗时较长的复杂运算
          console.log(vm.area);  // 9
        }
      }
    })
    console.log(vm.area);  // 4
    vm.length = 3
  </script>
</body>
</html>
